<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>健康之旅 - 登录</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
            -webkit-tap-highlight-color: transparent;
        }
        
        body {
            background: linear-gradient(135deg, #7ea681 0%, #c1dfc4 100%);
            min-height: 100vh;
            padding: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            line-height: 1.5;
        }
        
        #app {
            width: 100%;
            max-width: 450px;
        }
        
        .login-container {
            width: 100%;
            border-radius: 20px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        }
        
        .header {
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            padding: 30px 20px;
            text-align: center;
            color: white;
        }
        
        .title {
            font-size: 28px;
            font-weight: 700;
            display: block;
            margin-bottom: 8px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        .subtitle {
            font-size: 16px;
            opacity: 0.9;
            display: block;
        }
        
        .login-card {
            background: white;
            padding: 25px;
            border-radius: 0 0 20px 20px;
        }
        
        .input-group {
            margin-bottom: 20px;
        }
        
        .input-label {
            display: block;
            font-size: 16px;
            color: #2c3e50;
            margin-bottom: 8px;
            font-weight: 500;
        }
        
        .input-wrapper {
            position: relative;
            border: 1px solid #dcdfe6;
            border-radius: 8px;
            overflow: hidden;
            background: #f8f9fa;
            display: flex;
            align-items: center;
        }
        
        .input-field {
            flex: 1;
            padding: 15px;
            font-size: 16px;
            border: none;
            outline: none;
            background: transparent;
            color: #333;
            -webkit-user-select: auto;
            user-select: auto;
        }
        
        .input-field:focus {
            background: #fff;
        }
        
        .show-password {
            padding: 0 15px;
            color: #7ea681;
            font-size: 14px;
            background: transparent;
            cursor: pointer;
            white-space: nowrap;
        }
        
        .error-message {
            color: #e74c3c;
            font-size: 14px;
            margin-top: 5px;
            display: block;
            min-height: 20px;
        }
        
        .login-btn {
            width: 100%;
            background: linear-gradient(135deg, #7ea681 0%, #8bc34a 100%);
            color: white;
            border: none;
            padding: 15px;
            border-radius: 8px;
            font-size: 18px;
            font-weight: 500;
            margin-top: 10px;
            cursor: pointer;
            box-shadow: 0 4px 10px rgba(126, 166, 129, 0.3);
            transition: all 0.3s;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .login-btn:active {
            transform: translateY(2px);
            box-shadow: 0 2px 5px rgba(126, 166, 129, 0.3);
        }
        
        .login-btn.disabled {
            background: #cccccc;
            box-shadow: none;
            cursor: not-allowed;
        }
        
        .loading {
            display: inline-block;
            width: 18px;
            height: 18px;
            border: 2px solid rgba(255,255,255,.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 1s ease-in-out infinite;
            margin-right: 8px;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        .register-link {
            text-align: center;
            margin: 20px 0;
            color: #7ea681;
            font-weight: 500;
            font-size: 16px;
            cursor: pointer;
        }
        
        .terms {
            text-align: center;
            font-size: 14px;
            color: #777;
            line-height: 1.5;
            margin-top: 25px;
        }
        
        .terms .link {
            color: #7ea681;
            cursor: pointer;
        }
        
        .social-login {
            margin-top: 25px;
            text-align: center;
        }
        
        .social-title {
            position: relative;
            font-size: 14px;
            color: #999;
            margin-bottom: 15px;
        }
        
        .social-title:before,
        .social-title:after {
            content: '';
            position: absolute;
            top: 50%;
            width: 30%;
            height: 1px;
            background: #eee;
        }
        
        .social-title:before {
            left: 0;
        }
        
        .social-title:after {
            right: 0;
        }
        
        .social-icons {
            display: flex;
            justify-content: center;
            gap: 20px;
        }
        
        .social-icon {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f5f5f5;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 20px;
        }
        
        .social-icon:active {
            transform: scale(0.95);
        }
        
        .icon-wechat {
            color: #09BB07;
        }
        
        .icon-qq {
            color: #12B7F5;
        }
        
        .icon-apple {
            color: #000;
        }
        
        /* 修复iOS输入框圆角问题 */
        input {
            border-radius: 0;
            -webkit-appearance: none;
        }
        
        /* 移动端优化 */
        @media (max-width: 480px) {
            body {
                padding: 10px;
            }
            
            .login-card {
                padding: 20px 15px;
            }
            
            .header {
                padding: 25px 15px;
            }
            
            .title {
                font-size: 24px;
            }
            
            .subtitle {
                font-size: 14px;
            }
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="login-container">
            <!-- 顶部标题 -->
            <div class="header">
                <div class="title">开启健康之旅</div>
                <div class="subtitle">记录健康，享受生活</div>
            </div>
            
            <!-- 登录表单 -->
            <div class="login-card">
                <!-- 用户名/邮箱输入 -->
                <div class="input-group">
                    <div class="input-label">输入手机号/邮箱</div>
                    <div class="input-wrapper">
                        <input 
                            type="text" 
                            class="input-field" 
                            placeholder="请输入手机号或邮箱"
                            v-model="formData.username"
                            @focus="clearError('username')"
                        />
                    </div>
                    <div class="error-message" v-if="errors.username">{{ errors.username }}</div>
                </div>
                
                <!-- 密码输入 -->
                <div class="input-group">
                    <div class="input-label">输入密码</div>
                    <div class="input-wrapper">
                        <input 
                            :type="passwordVisible ? 'text' : 'password'" 
                            class="input-field" 
                            placeholder="请输入密码"
                            v-model="formData.password"
                            @focus="clearError('password')"
                        />
                        <div class="show-password" @click="togglePasswordVisible">
                            {{ passwordVisible ? '隐藏' : '显示' }}
                        </div>
                    </div>
                    <div class="error-message" v-if="errors.password">{{ errors.password }}</div>
                </div>
                
                <!-- 登录按钮 -->
                <button 
                    class="login-btn" 
                    :class="{ disabled: isLoading }"
                    @click="handleSubmit"
                    :disabled="isLoading"
                >
                    <div class="loading" v-if="isLoading"></div>
                    {{ isLoading ? '登录中...' : '登录' }}
                </button>
                
                <!-- 注册链接 -->
                <div class="register-link" @click="navigateToRegister">
                    没有账号？立即注册
                </div>
                
                <!-- 社交登录 -->
                <div class="social-login">
                    <div class="social-title">其他登录方式</div>
                    <div class="social-icons">
                        <div class="social-icon icon-wechat"><i class="fab fa-weixin"></i></div>
                        <div class="social-icon icon-qq"><i class="fab fa-qq"></i></div>
                        <div class="social-icon icon-apple"><i class="fab fa-apple"></i></div>
                    </div>
                </div>
                
                <!-- 用户协议 -->
                <div class="terms">
                    <span>登录/注册表示您同意</span>
                    <span class="link" @click="navigateToAgreement">《用户协议》</span>
                    <span>和</span>
                    <span class="link" @click="navigateToPrivacy">《隐私政策》</span>
                </div>
            </div>
        </div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    // 表单数据
                    formData: {
                        username: '',
                        password: ''
                    },
                    // 错误信息
                    errors: {
                        username: '',
                        password: ''
                    },
                    // 密码是否可见
                    passwordVisible: false,
                    // 是否正在加载
                    isLoading: false
                }
            },
            methods: {
                /**
                 * 切换密码可见性
                 */
                togglePasswordVisible() {
                    this.passwordVisible = !this.passwordVisible;
                },
                
                /**
                 * 清除错误信息
                 * @param {String} field - 字段名
                 */
                clearError(field) {
                    this.errors[field] = '';
                },
                
                /**
                 * 表单验证
                 * @returns {Boolean} 是否通过验证
                 */
                validateForm() {
                    let isValid = true;
                    
                    // 清空之前的错误信息
                    this.errors = {
                        username: '',
                        password: ''
                    };
                    
                    // 验证用户名
                    if (!this.formData.username) {
                        this.errors.username = '请输入手机号或邮箱';
                        isValid = false;
                    } else if (!this.isValidUsername(this.formData.username)) {
                        this.errors.username = '请输入有效的手机号或邮箱';
                        isValid = false;
                    }
                    
                    // 验证密码
                    if (!this.formData.password) {
                        this.errors.password = '请输入密码';
                        isValid = false;
                    } else if (this.formData.password.length < 6) {
                        this.errors.password = '密码长度不能少于6位';
                        isValid = false;
                    }
                    
                    return isValid;
                },
                
                /**
                 * 验证用户名格式（手机号或邮箱）
                 * @param {String} username - 用户名
                 * @returns {Boolean} 是否有效
                 */
                isValidUsername(username) {
                    // 手机号正则（11位数字）
                    const phoneRegex = /^1[3-9]\d{9}$/;
                    // 邮箱正则
                    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                    
                    return phoneRegex.test(username) || emailRegex.test(username);
                },
                
                /**
                 * 处理表单提交
                 */
                handleSubmit() {
                    // 验证表单
                    if (!this.validateForm()) {
                        return;
                    }
                    
                    // 设置加载状态
                    this.isLoading = true;
                    
                    // 模拟API请求
                    setTimeout(() => {
                        this.isLoading = false;
                        
                        // 模拟登录成功
                        alert('登录成功！');
                        
                        // 在实际应用中，这里会跳转到首页
                        // this.$router.push('/home');
                    }, 1500);
                },
                
                /**
                 * 跳转到注册页面
                 */
                navigateToRegister() {
                    alert('跳转到注册页面');
                    // 在实际应用中，这里会进行页面跳转
                    // this.$router.push('/register');
                },
                
                /**
                 * 跳转到用户协议页面
                 */
                navigateToAgreement() {
                    alert('跳转到用户协议页面');
                    // 在实际应用中，这里会进行页面跳转
                },
                
                /**
                 * 跳转到隐私政策页面
                 */
                navigateToPrivacy() {
                    alert('跳转到隐私政策页面');
                    // 在实际应用中，这里会进行页面跳转
                }
            }
        });
    </script>
</body>
</html>